/*
 * <p>Copyright® 2009-2022 东软 IT 实训中心版权所有。</p>
 */

package com.max.back.doctor.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.max.back.doctor.dao.RegistrationDao;
import com.max.back.doctor.service.RegistrationService;
import com.max.back.entity.Registration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
* @description 
* 
* <p>
* <code>RegistrationServiceImpl</code>
*
* </p>
* @see 
* @author 辛凤文 forward.seen@foxmail.com
* @version 1.0 
* @time 2022/7/20 13:00 
*/
@Service
public class RegistrationServiceImpl extends ServiceImpl<RegistrationDao,
        Registration> implements RegistrationService {

    @Autowired
    private RegistrationDao dao;

    @Override
    public int getRegistrationCountByDoctor(String doctorId) {
        int count = count(new QueryWrapper<Registration>().and(i -> {
            i.eq("DELETED", 0).eq("DOCTOR_ID", doctorId);
        }));
        return count;
    }

    @Override
    public List<Map<String,Object>> registrationPatientBaseInfo(String doctorId){
        return dao.queryRegistrationPatientBaseInfo(doctorId);
    }

    @Override
    public PageInfo<Map<String, Object>> registrationPatientBaseInfoPage(String doctorId, int pageNum, int pageSize) {
        //指定页码和单页的记录数
        PageHelper.startPage(pageNum,pageSize);
        List<Map<String, Object>> list = dao.queryRegistrationPatientBaseInfo(doctorId);
        PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Integer getRegistrationStatusById(String registrationId) {
        return getById(registrationId).getRegisterStatus();
    }

}